import 'package:aidou/http/api.dart';
import 'package:aidou/http/http_manager.dart';
import 'package:aidou/model/video.dart';

class HomeRepository {
  /// 获取首页视频列表数据
  static Future<List<VideoData>> getVideoList({
    required int pageIndex,
    required int pageSize,
    required int type,
  }) async {
    Map<String, dynamic> result = await HttpManager.getInstance().post(
      Api.GET_WORKS_LIST,
      data: {
        'pageIndex': pageIndex,
        'pageSize': pageSize,
        'type': type,
      },
    );
    List<VideoData> videoList = videoInfoFromJson(result['data'] ?? []);
    return videoList;
  }

  // 获取第三方视频播放地址
  static Future<String> getPlayUrl({required int businessId}) async {
    Map<String, dynamic> result = await HttpManager.getInstance().post(
      Api.GET_PLAY_URL,
      data: {'businessId': businessId},
    );
    return result['data'];
  }
}
